﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>

<%@ Register Assembly="DevExpress.Web.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxHiddenField" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Đăng nhập</title>    
    <link href="../../style.css" rel="stylesheet" type="text/css" />
    <link href="../../css/logincss.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header">
        <div id="top-menu">
        </div>
        <div id="sitename">
            <a class="logo float-left" title="Quản lý thu phí" > Quản Lý Thu Phí </a>
            <div class="button float-right">
            </div>
        </div>
    </div>
    <div class="clearfix">
    </div>
    <div style="min-height: 580px; background-color: #fefefe">
        <form id="form1" runat="server">
        <div style="border-top: 13px solid #ffffff;"></div>
        <div id="login-wrapper">
            <div class="content-login">
                <div class="header-login">
                    Đăng nhập
                </div>
                <div class="form-login">
                    
                    <div class="br-px">
                    </div>
                    <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="Tài khoản">
                    </dx:ASPxLabel>
                    <div class="br-px">
                    </div>
                    <dx:ASPxTextBox ID="txtUsername" ClientInstanceName="txtUsername" runat="server" Width="100%" ClientIDMode="AutoID">
                    <ClientSideEvents KeyUp="function(s,e){keyupontextbox();}"/>
                    </dx:ASPxTextBox>
                    <div class="br-px">
                    </div>
                    <dx:ASPxLabel ID="ASPxLabel4" runat="server" Text="Mật khẩu">
                    </dx:ASPxLabel>
                    <div class="br-px">
                    </div>
                    <dx:ASPxTextBox ID="txtPass" ClientInstanceName="txtPass" runat="server" Width="100%" ClientIDMode="AutoID" Password="true">
                    <ClientSideEvents KeyUp="function(s,e){keyupontextbox();}"/>
                    </dx:ASPxTextBox>
                    <div class="br-px">
                    </div>
                    <dx:ASPxLabel ID="lbMess" ClientInstanceName="lbMess" runat="server" ForeColor="Maroon" Text="">
                    </dx:ASPxLabel>
                    <div class="br-px">
                    </div>
                    <dx:ASPxCheckBox ID="chkb" ClientInstanceName="chkb" runat="server" Text="Nhớ tài khoản" Checked="true">
                    </dx:ASPxCheckBox>
                    <div class="br-px">
                    </div>
                    <dx:ASPxButton ID="ASPxButton1" ClientInstanceName="ASPxButton1" runat="server" Text="Đăng nhập" ImagePosition="Right"
                        OnClick="btnLogin_Click">
                    <ClientSideEvents Init="function(s,e){btninit();}" Click="function(s,e){btnclick();}"/>
                    </dx:ASPxButton>
                    
                    <script type="text/javascript">
                        function btninit() {
                            if (txtUsername.GetText() == '' || txtPass.GetText() == '') {
                                ASPxButton1.SetEnabled(false);
                            }
                            if (txtUsername.GetText() != '' && txtPass.GetText() != '') {
                                ASPxButton1.SetEnabled(true);
                            }
                        }
                        function checkhideshowbtn() {
                            if (txtUsername.GetText() != '' && txtPass.GetText() != '') {
                                ASPxButton1.SetEnabled(true);
                            }
                            if (txtUsername.GetText() == '' || txtPass.GetText() == '') {
                                ASPxButton1.SetEnabled(false);
                            }
                        }
                        function keyupontextbox() {
                            lbMess.SetValue('');
                            checkhideshowbtn();
                        }
                        function btnclick() {
                            var x = chkb.GetValue().toString();
                            var y = txtUsername.GetValue();
                            if (y == null || y == '') y = '';
                            var z = txtPass.GetValue();
                            if (z == null || z == '') z = '';
                            if (x == "true") {
                                createCookie('ac', y, 1);
                                createCookie('pw', z, 1);
                                createCookie('chkb', x, 1);
                            } else {
                                deleteCookie('ac');
                                deleteCookie('pw');
                                deleteCookie('chkb');
                            }
                        }
                        //function ddd() {
                        //    var y = (readCookie('chkb') == "true") ? true : false;
                            //alert('y='+y);
                        //    chkb.SetValue(y);
                        //}
                        window.onload = function () {
                            if (readCookie('chkb') == "true") {
                                txtUsername.SetValue(readCookie('ac'));
                                txtPass.SetValue(readCookie('pw'));
                                chkb.SetValue(true);
                            } else {
                                txtUsername.SetValue('');
                                txtPass.SetValue('');
                                chkb.SetValue(false); //chkb.SetChecked(false);
                                deleteCookie('ac');
                                deleteCookie('pw');
                                deleteCookie('chkb');
                            }
                            checkhideshowbtn();
                        }
                        ////////
                        function createCookie(namecookie, value, days) {
                            if (days) {
                                var date = new Date();
                                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                                var expires = "; expires=" + date.toGMTString();
                            }
                            else
                                var expires = "";

                            document.cookie = namecookie + "=" + value + expires + "; path=/";
                        }
                        function readCookie(namecookie) {
                            var nameEQ = namecookie + "=";
                            var ca = document.cookie.split(';'); //var ca = document.cookie.split(';');
                            for (var i = 0; i < ca.length; i++) {
                                var c = ca[i];
                                while (c.charAt(0) == ' ')
                                    c = c.substring(1, c.length);
                                if (c.indexOf(nameEQ) == 0)
                                    return c.substring(nameEQ.length, c.length);
                            }
                            return null;
                        }
                        function deleteCookie(namecookie) {
                            createCookie(namecookie, "", -1);
                        }
                    </script>
                </div>
            </div>
        </div>
        </form>
    </div>    
    <div class="clearfix">
    </div>
    <div id="footer">
        <%--<div id="menu">
            <a href="" title="Home">Home</a> <a href="" title="Administration">Administration</a>
            <a href="" title="Settings">Settings</a> <a href="" title="Contact">Contact</a>
        </div>--%>
        Copyright &copy; 2012 - TRUNG TÂM NGOẠI NGỮ & TIN HỌC ANH VIỆT <br /> <br />
        <a  href="http://anhviet.edu.vn" target="_blank" style="color:Silver; font-size:13px;"> http://anhviet.edu.vn  </a>
    </div>
</body>
</html>
